const fp= require('lodash/fp')
const {MayBe,Container} =require('./supports/support');
let mayBe = MayBe.of([5,6,1]);
let ex1 =()=>{
    
   let add =fp.curry((x,y)=>{ return fp.add(x,y)})
   let y=10;//每一项增加 数
   return fp.map(itemValue=>add(y)(itemValue) ,mayBe._value)
}
//console.log(ex1)
console.log(mayBe.map(ex1));
//2
let xs =Container.of(["do","ray","me"])

let ex2=()=>{
    return fp.first(xs._value)
}
console.log(xs.map(ex2));
//3
let safeProp =fp.curry(function(x,o){
    return MayBe.of(o[x]);
})
let user = {id:2,name:'Albert'}
let ex3=()=>{
    let value = safeProp('name',user)._value; 
    
    return fp.first(value);
}
console.log(ex3());
//4
//let mayBeInst = MayBe.of("100")
let mayBeInst = MayBe.of(null)
let ex4 =()=>{
   
    mayBeInst.map(x=>parseInt(x))
    return mayBeInst._value;
}
console.log(mayBeInst.map(ex4));